package com.aiyige.page.my.customer.adapter;

import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.aiyige.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class DialogListAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    public DialogListAdapter() {
        super(new LinkedList<String>());
    }

    String selectedString = "";
    @Override
    protected void convert(BaseViewHolder helper, String item) {
        ((MyHolder) helper).bindData(item);
    }

    @Override
    protected BaseViewHolder onCreateDefViewHolder(ViewGroup parent, int viewType) {
        BaseViewHolder baseViewHolder = new MyHolder(getItemView(R.layout.item_text, parent));
        return baseViewHolder;
    }

    public void setSelected(String selectedString) {
        this.selectedString =  selectedString;
    }


    public class MyHolder extends BaseViewHolder {

        @BindView(R.id.tv_text)
        TextView tvText;

        public MyHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }


        public void bindData(String data) {
            tvText.setText(data);
            if (!TextUtils.isEmpty(selectedString)) {
                tvText.setSelected(data.equals(selectedString));
            }
        }

    }



}
